import time

import paho.mqtt.client as mqtt

HOST = "139.217.237.110"
PORT = 1883


def test():
    client = mqtt.Client()
    client.connect(HOST, PORT, 60)
    client.publish("control", "hello world")
    time.sleep(2)
    client.publish("control","hello world every body")
    client.loop_forever()  # 延时堵塞


if __name__ == '__main__':
    test()
